<template>
  <tbody>
    <tr v-for="(item, index) in goodList" :key="index">
      <td>
        <input
          type="checkbox"
          :checked="item.checked"
          @click="chooseFn(index)"
        />
      </td>
      <td>{{ item.name }}</td>
      <td>{{ item.price }}</td>
      <td>
        <button @click="$emit('cutNum', index)">-</button>{{ item.num
        }}<button @click="$emit('addNum', index)">+</button>
      </td>
      <td>{{ item.price * item.num }}</td>
      <td><button @click="$emit('delItem', index)">删除</button></td>
    </tr>
  </tbody>
</template>

<script>
export default {
  props: {
    goodList: {
      type: Array,
      required: true,
    },
  },
  methods: {
    chooseFn(index) {
      this.$emit('choose', index)
    },
  },
}
</script>

<style>
tbody {
  text-align: center;
}
</style>
